﻿/******************************************************************************
* File description: ControlPannelButton.qml
* Function: 实验控制按钮组件（之前圆形的那版，已弃用）
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.0

Item {

    id: root

    property string icon: "qrc:/picture/controlPannelButton/run.png"
    property string title: "运行"
    property real buttonSize: 50*dp

    property bool enabled: true

    signal clicked()

    property bool isHovered: false

    width: buttonSize
    height: buttonSize + 24*dp

    CustomImage{
        id: image
        source: root.icon
        height: buttonSize + ((isHovered&&root.enabled) ? 4*dp : 0)
        width: buttonSize + ((isHovered&&root.enabled) ? 4*dp : 0)
        x: (isHovered&&root.enabled) ? -2*dp : 0
        y: (isHovered&&root.enabled) ? -2*dp : 0
    }
    Text {
        text: qsTr(title)
        y: parent.height - contentHeight
        anchors.horizontalCenter: parent.horizontalCenter
        font.pixelSize: config.fontsize
    }
    MouseArea{
        anchors.fill: image
        hoverEnabled: true
        cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
        onClicked: {
            if(root.enabled){
                root.clicked()
            }
        }
        onEntered: {
            isHovered = true
        }onExited: {
            isHovered = false
        }
    }


}
